class Validate {
  isNumber(value) {
    return typeof value === 'number';
  }

  isNumberObject(value) {
    return value instanceof Number;
  }

  isBoolean(value) {
    return typeof value === 'boolean';
  }

  isBooleanObject(value) {
    return value instanceof Boolean;
  }

  isString(value) {
    return typeof value === 'string';
  }

  isStringObject(value) {
    return value instanceof String;
  }

  isFunction(value) {
    return typeof value === 'function';
  }

  isObject(value) {
    return Object.prototype.toString.call(value) === '[object Object]';
  }

  isEmptyObject(obj) {
    let arr = Object.keys(obj);
    return arr.length === 0
  }

  isObjectObject(value) {
    return typeof value === 'object';
  }

  isUndefined(value) {
    return typeof value === 'undefined';
  }

  isArray(value) {
    return value instanceof Array;
  }

  isPromise(value) {
    return value instanceof Promise;
  }

  isArrayBuffer(value) {
    return value instanceof ArrayBuffer;
  }

  isEmail(email) {
    const re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
    return re.test(email);
  }

  isURL(textval) {
    const urlregex = /^(https?|ftp):\/\/([a-zA-Z0-9.-]+(:[a-zA-Z0-9.&%$-]+)*@)*((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}|([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(:[0-9]+)*(\/($|[a-zA-Z0-9.,?'\\+&%$#=~_-]+))*$/;
    return urlregex.test(textval);
  }
}
export default new Validate();
